package com.edu.exam.enums.grading;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 质量审核状态枚举
 *
 * 管理质量审核的状态流程，包括待审核、已批准、已拒绝、已修订等状态
 *
 * @author System
 * @version 1.0.0
 */
public enum QualityReviewStatus implements BaseEnum {

    /**
     * 待审核
     */
    PENDING("PENDING", "待审核"),

    /**
     * 已批准
     */
    APPROVED("APPROVED", "已批准"),

    /**
     * 已拒绝
     */
    REJECTED("REJECTED", "已拒绝"),

    /**
     * 已修订
     */
    REVISED("REVISED", "已修订");

    private final String code;
    private final String description;

    QualityReviewStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    /**
     * 从代码创建枚举实例
     *
     * @param code 枚举代码
     * @return 对应的枚举实例
     */
    public static QualityReviewStatus fromCode(String code) {
        for (QualityReviewStatus status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown quality review status code: " + code);
    }

    /**
     * 从描述创建枚举实例
     *
     * @param description 枚举描述
     * @return 对应的枚举实例
     */
    public static QualityReviewStatus fromDescription(String description) {
        for (QualityReviewStatus status : values()) {
            if (status.getDescription().equals(description)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown quality review status description: " + description);
    }

    @Override
    public String toString() {
        return description;
    }
}